{% extends "layout.html" %}

{% block title %}注册 - 金融数据平台{% endblock %}

{% block content %}
<div class="row justify-content-center">
    <div class="col-md-6">
        <div class="card">
            <div class="card-header bg-primary text-white">
                <h4 class="mb-0"><i class="fas fa-user-plus me-2"></i>用户注册</h4>
            </div>
            <div class="card-body">
                <form method="POST" action="{{ url_for('register') }}">
                    {{ form.hidden_tag() }}
                    <div class="mb-3">
                        <label for="username" class="form-label">用户名</label>
                        {{ form.username(class="form-control", id="username", placeholder="请输入3-20个字符的用户名") }}
                        {% if form.username.errors %}
                        <div class="text-danger">
                            {% for error in form.username.errors %}
                            <small>{{ error }}</small>
                            {% endfor %}
                        </div>
                        {% endif %}
                    </div>
                    <div class="mb-3">
                        <label for="email" class="form-label">电子邮箱</label>
                        {{ form.email(class="form-control", id="email", placeholder="请输入有效的电子邮箱地址") }}
                        {% if form.email.errors %}
                        <div class="text-danger">
                            {% for error in form.email.errors %}
                            <small>{{ error }}</small>
                            {% endfor %}
                        </div>
                        {% endif %}
                    </div>
                    <div class="mb-3">
                        <label for="password" class="form-label">密码</label>
                        {{ form.password(class="form-control", id="password", placeholder="请输入至少6个字符的密码") }}
                        {% if form.password.errors %}
                        <div class="text-danger">
                            {% for error in form.password.errors %}
                            <small>{{ error }}</small>
                            {% endfor %}
                        </div>
                        {% endif %}
                    </div>
                    <div class="mb-3">
                        <label for="confirm_password" class="form-label">确认密码</label>
                        {{ form.confirm_password(class="form-control", id="confirm_password", placeholder="请再次输入密码") }}
                        {% if form.confirm_password.errors %}
                        <div class="text-danger">
                            {% for error in form.confirm_password.errors %}
                            <small>{{ error }}</small>
                            {% endfor %}
                        </div>
                        {% endif %}
                    </div>
                    <div class="d-grid gap-2">
                        {{ form.submit(class="btn btn-primary") }}
                    </div>
                </form>
            </div>
            <div class="card-footer text-center">
                <p class="mb-0">已有账号？<a href="{{ url_for('login') }}">立即登录</a></p>
            </div>
        </div>
    </div>
</div>
{% endblock %}